<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title><?=$da['title']?></title>
<link rel="stylesheet" type="text/css" href="mode/weui/weui.min.css"/>
<link rel="stylesheet" type="text/css" href="web/res/fontawesome/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="webmain/css/rui.css">
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/js.js"></script>
<script type="text/javascript" src="js/jswx.js"></script>
<script type="text/javascript" src="js/base64-min.js"></script>
<script charset="utf-8" src="http://map.qq.com/api/js?v=2.exp"></script>
<style>

</style>
<script>
var infoWin;
function initbody(){
	js.jssdkwixin();
	var lata = js.getoption('latlongedu','24.504332,118.141136,12').split(',');
	if(!lata[2])lata[2]=12;
	var center = new qq.maps.LatLng(parseFloat(lata[0]), parseFloat(lata[1]));
	map = new qq.maps.Map(document.getElementById('container'),{
        center: center,
        zoom: parseFloat(lata[2])
    });
	geocoder = new qq.maps.Geocoder({
        complete : function(result){
			dwbool=false;
			var center = result.detail.location;
            map.setCenter(center);
			var address = result.detail.address;
			var dzarr 	= result.detail.addressComponents;
			address = ''+dzarr.province+''+dzarr.city+''+dzarr.district+''+dzarr.street+'';
			if(dzarr.streetnumber)address+=dzarr.streetnumber;
			var label = address+'';
			address+='(精确'+accuracy+'米)';
			if(!infoWin)infoWin = new qq.maps.InfoWindow({
				map: map
			});
			infoWin.open();
			infoWin.setContent('定位成功<br>地址：'+address+'');
			infoWin.setPosition(center);
			var data = {location_x:latitude,location_y:longitude,scale:scale,precision:accuracy,label:jm.base64encode(label)};
			js.ajax('weixin','addlocation',data,function(ret){
				js.msg('success','保存成功');
			},'none');
        }
    });
}
var dwbool=false;
function dingweidak(){
	if(dwbool)return;
	if(!js.iswxbo()){
		htmldingw();
		return;
	}
	if(!js.jssdkstate){js.msg('msg','微信jssdk验证失败，无法使用');return;}
	js.msg('wait','定位中...');
	dwbool=true;
	wx.getLocation({
		type: 'gcj02',
		success: function (res){
			js.setmsg('');
			latitude = res.latitude;
			longitude = res.longitude;
			scale=map.getZoom();
			js.setoption('latlongedu',''+latitude+','+longitude+','+scale+'');
			accuracy = res.accuracy;
			var center = new qq.maps.LatLng(latitude, longitude);
			geocoder.getAddress(center);
		},
		error:function(){
			js.msg('msg','定位失败');
		}
	});
}
function htmldingw(){
	js.msg('msg','请使用微信企业号定位打卡');
	return;
	if(!navigator.geolocation){
		js.wx.alert('不能定位');
	}else{
		js.msg('wait','使用浏览器定位中...');
		navigator.geolocation.getCurrentPosition(showPosition,showError);
	}
}
function showError(error){
	js.setmsg('');
	var msg='无法定位';
	switch(error.code)
    {
    case error.PERMISSION_DENIED:
      msg="用户拒绝对获取地理位置的请求。"
      break;
    case error.POSITION_UNAVAILABLE:
      msg="位置信息是不可用的。"
      break;
    case error.TIMEOUT:
      msg="请求用户地理位置超时。"
      break;
    case error.UNKNOWN_ERROR:
      msg="未知错误。"
      break;
    }
	js.msg('msg', msg);
}
function showPosition(position){
	js.msg('');
	latitude = position.coords.latitude;
	longitude = position.coords.longitude;
	scale=12;
	js.getarr(position);
} 
</script>
</head>


<body>
<?php if($web!='wxbro'){?>
<div>
	<div class="r-header">
		<div class="r-header-text" id="header_title"><?=$da['title']?></div>
		<span onclick="js.back()" class="r-position-left r-header-btn"><i class="icon-chevron-left"></i></span>
	</div>
	<div class="blank50"></div>
</div>
<?php }?>

<div>
	<div style="width:100%;height:340px" id="container"></div>
	
	<div style="padding:10px">
	<button type="button" onClick="dingweidak()" class="weui_btn weui_btn_primary" name="button"><i class="icon-map-marker"></i> 定位打卡</button>
	</div>
	<div style="padding:0px 10px">
		<div><b>今日我的外勤：</b></div>
		<?php
		foreach($rows as $k=>$rs){
			echo '<div style="font-size:14px">'.($k+1).'.['.$rs['atype'].']'.$rs['address'].','.$rs['reason'].'('.$rs['outtime'].')</div>';
		}
		?>
	</div>




</div>

</body>
</html>